<template>
  <div>
    <Header :active="5"/>
    <div class="news-details-content">
      <div class="banner">
        <img style="width: 100%" src="../../static/image/news-banner-details.jpg">
      </div>
      <!--新闻详情-->
      <div   class="news-details">
        <div class="common-width title">{{newsDetail.title}}</div>
        <div class="common-width time">作者:{{newsDetail.author}}</div>
        <div class="common-width time">{{ dateFormat(newsDetail.gmtCreate,'yyyy-MM-dd ')}}</div>

        <div class="common-width"> <el-divider></el-divider></div>
        <div class="common-width content">
          <div class="fl content-desc" :style="{width:teamWidth+'px'} "v-html="newsDetail.content" style="line-height: 35px"></div>
          <div class="fr content-list">
            <div class="content-list-header">相关内容</div>
            <el-divider></el-divider>
            <div class="item"  v-for=" items in news">
              <div class="title"><a @click="goMore(items.id)">{{items.title}}</a></div>
              <div class="desc">{{items.description}}</div>
            </div>

          </div>
        </div>
      </div>




    </div>
    <Footer/>
  </div>
</template>
<script>

  import Header from '@/components/Header'
  import Footer from '@/components/Footer'
  import {formatDate} from '@/utils/global'

  export default {
    components: {Header, Footer},
    filters: {},
    data() {
      return {
        id: undefined,
        teamWidth: 0,
        newsDetail:{},
        news: [],

      }
    },
    mounted() {


    },
    watch: {
      "$route": "reload"    //后面是methods中的一个方法
    },
    created() {
      this.id = this.$route.params && this.$route.params.id;
        this.teamWidth = 1190 - 465-125;
      let _self = this;
      _self.$store.dispatch('newsDetail', {id:this.id}).then(response => {
        _self.newsDetail = response.data;
      }).catch(() => {
      })
      _self.$store.dispatch('news', {}).then(response => {
        this.news = response.data;
      }).catch(() => {
      })
    },
    methods: {
      fetchData() {

        let _self = this;
        _self.$store.dispatch('statisticsProjectStatus', {}).then(response => {
          _self.list = response.data;
          _self.total = response.count;
        }).catch(() => {
        })
      },
      goMore(id){
        window.location.href = "#/news/" + id ;
        location.reload();
      },
      dateFormat(d, fmt) {
      return formatDate(d, fmt);
      }
    }
  }

</script>
<style>
.content-desc img{
  width: 100%;
}
</style>
